<?php

/**
 * This is the model class for table "site_links".
 *
 * The followings are the available columns in table 'site_links':
 * @property string $links_id
 * @property string $links_title
 * @property string $links_url
 * @property string $links_description
 * @property string $links_image
 * @property string $links_order_by
 * @property string $links_is_active
 */
class site_links extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return site_links the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'site_links';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('links_title, links_url', 'required'),
            array('links_title', 'length', 'max' => 100),
            array('links_url, links_image', 'length', 'max' => 255),
            array('links_order_by', 'length', 'max' => 10),
            array('links_is_active', 'length', 'max' => 1),
            array('links_description', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('links_id, links_title, links_url, links_description, links_image, links_order_by, links_is_active', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'links_id' => 'Links',
            'links_title' => 'Links',
            'links_url' => 'Url',
            'links_description' => 'Links Description',
            'links_image' => 'Image',
            'links_order_by' => 'Order By',
            'links_is_active' => 'Is Active',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('links_id', $this->links_id, true);
        $criteria->compare('links_title', $this->links_title, true);
        $criteria->compare('links_url', $this->links_url, true);
        $criteria->compare('links_description', $this->links_description, true);
        $criteria->compare('links_image', $this->links_image, true);
        $criteria->compare('links_order_by', $this->links_order_by, true);
        $criteria->compare('links_is_active', $this->links_is_active, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

}